define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'knscy.pages/index',
        add_url: 'knscy.pages/add',
        edit_url: 'knscy.pages/edit',
        delete_url: 'knscy.pages/delete',
        export_url: 'knscy.pages/export',
        modify_url: 'knscy.pages/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'ID'},
                    {field: 'sort', title: '排序',minWidth:80, search:'false', edit: 'text'},
                    {field: 'cate_id', title: '分类' ,minWidth: 100,search: 'select',selectList: $nodes.category },
                    {field: 'title', title: '标题名称', minWidth: 200, edit: 'text', },
                    {field: 'sub_title', title: '副标题', minWidth: 150, edit: 'text', },
                    {field: 'cover', title: '图片', minWidth: 100,  imageHeight: 25, search:false, templet: ea.table.image},
                    {field: 'url', title: '链接', minWidth: 200, search: false, templet: function (d){
                            return "/pages/single/index?id="+d.id;
                        } },
                    {field: 'status', search: 'select', selectList: ["禁用","启用"], title: '状态', templet: ea.table.switch},
                    {field: 'create_time', title: '创建时间',minWidth: 180 , search:"range"},
                    {fixed:"right",width: 150, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});